.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.nh
.ad l

.TH "py-ini-config" "1" "2024-05-31"
.P
.SH NAME
.P
py-ini-config - utility to work with a ini-like config files.\&
.P
.SH SYNOPSIS
.P
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config set [-c, --create] file [section, -n, --no-section] var value [-s separator] [-S values_separator] [--no-indent] [--view-comments] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config add [-c, --create] file [section, -n, --no-section] var value [-s separator] [-S values_separator] [--no-indent] [--view-comments] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config comment file [section, -n, --no-section] [var] [-s separator] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config uncomment file [section, -n, --no-section] [var] [-s separator] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config get file [section, -n, --no-section] [var] [-s separator] [-S values_separator] [-a, --all file1 -a file2...] [-i]  [-e extension] [--sort-collected] [--shadowing] [-v, --verbose]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config is_set file [section, -n, --no-section] var [value] [-s separator] [-S values_separator] [-a, --all file1 -a file2...] [-e extension] [--sort-collected] [--shadowing]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config get_commented file [section, -n, --no-section] var [-s separator] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config del file [section, -n, --no-section] var [value] [-s separator] [-f, --flush] [--semicolon-comment]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config del_section file section [-s separator]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config is_empty file section [-s separator]
.RE
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.IP \(bu 4
.\}
py-ini-config rename file [section, -n, --no-section] var new_name [-s separator]

.RE
.P
.SH DESCRIPTION
.P
.SS -s \fBseparator\fR
If set, uses a specified \fBseparator\fR in the config file instead of '='.\&
.P
.SS -n, --no-section
If set instead of \fBsection\fR, switches work to the config files with no sections at all.\&
.P
.SS -c, --create
If set, creates a new config file. If the file exists, continues working with the existing file. Uses with set or add.\&
.P
.SS -a, --all
Used instead of a single file with \fBget\fR and \fBis_set\fR functions. A filename following this flag is both a filename and the name for the directory without \'.d\' at the end. The specified \fBvar\fR will be searched for in all the files in a folder as well as in the file with the given filename.\&
.P
.SS -i
Used with -a, --all. If specified, \fBvar\fR will be searched for first in the folder, then in the file itself.\&
.P
.SS -e
Used with -a, --all. If set, only files with the specified extension will be looked through.\&
.P
.SS --sort-collected
Used with -a, --all. If set, all files from folders are alphabetically sorted together before being looked through.\&
.P
.SS --shadowing
Used with -a, --all. If set, the last found file from the files with the same basename replaces the files that are found before.\&
.P
.SS --flush
If used with del, the \fBsection\fR with no variables left will be deleted.\&
.P
.SS --no-indent
If used with set or add, and the value to the existing variable is set, removes the indent before the string.\&
.P
.SS -S
If set, the specified values separator is used instead of a comma.\&
.P
.SS --semicolon-comment
If set, a semicolon is used as a commenting symbol instead of \'#\'.\&
.P
.SS --view-comments
Used with set and add commands. If set, the specified value can be set or added to the commented variable, that also uncomments the whole line.\&
.P
.SS -v, --verbose
Used with -a, --all. If set, outputs detailed information to stderr while working.\&
.P
.SS set
The function sets \fBvalue\fR or adds (if there is no variable specified) a variable \fBvar\fR with the \fBvalue\fR in the \fBsection\fR.\& If this \fBsection\fR doesn't exist, it will be created.\&
.P
.SS add
The function adds \fBvalue\fR specified to a variable \fBvar\fR in the \fBsection\fR.\& If this variable or \fBsection\fR doesn't exist, it will be created.\&
.P
.SS comment
The function comments \fBvar\fR variable in a specific \fBsection\fR or the entire \fBsection\fR as a whole.\&
.P
.SS uncomment
The function uncomments \fBvar\fR variable in a specific \fBsection\fR or the entire \fBsection\fR as a whole.\&
.P
.SS get
The function outputs \fBvar\fR variable in a specific \fBsection\fR from the config \fBfile\fR. If no \fBvar\fR specified, outputs the whole \fBsection\fR.\&
.P
.SS is_set
The function outputs nothing.\& It only checks that \fBvar\fR variable exists in a specific \fBsection\fR.\&
Returns 0 if variable \fBvar\fR was found, otherwise returns 1. If \fBvalue\fR is specified, returns 0 if \fBvalue\fR is in the variable's values, otherwise returns 1.\&
.P
.SS get_commented
The function outputs the value of a commented \fBvar\fR variable in a specific \fBsection\fR from the config \fBfile\fR.\&
.P
.SS del
The function removes a variable in the specified \fBsection\fR from the config \fBfile\fR. If \fBvalue\fR is specified, removes it from the variable's values.\&
.P
.SS del_section
The function removes the entire \fBsection\fR from the config \fBfile\fR.\&
.P
.SS is_empty
The function outputs nothing.\& It only checks that the specified \fBsection\fR is empty.\&
Returns 0 if it is empty, otherwise returns 1.\&
.P
.SS rename
Renames a specified \fBvar\fR in the \fBsection\fR to \fBnew_name\fR.\&
.P
.SS -V, --version
Shows current version of py-ini-config.\&
.P
.SH EXAMPLES
.TP
py-ini-config set /etc/sddm.conf.d/50-default.conf Theme CursorSize 10
Sets the variable \fBCursorSize\fR in the section \fBTheme\fR in the file /etc/sddm.conf.d/50-default.conf value 10.
.TP
py-ini-config get /etc/e2scrub.conf -n scrub_all
Gets the value of the variable \fBscrub_all\fR in the specified file \fB/etc/e2scrub.conf\fR.
.TP
py-ini-config is_set -a /etc/file.conf --all /etc/x11.conf Theme Current -e conf
Returns 0 if the variable \fBCurrent\fR in the section \fBTheme\fR in any of the files \fB/etc/file.conf\fR, \fB/etc/x11.conf\fR or in the folders /etc/file.conf.d and /etc/x11.conf.d is set (but only the files with the extension .conf are looked through). Otherwise returns 1.
.TP
py-ini-config get Autologin User -a /usr/lib/sddm/sddm.conf -a /etc/sddm.conf -i
Returns the \fBUser\fR variable value in the section \fBAutologin\fR for SDDM. As SDDM has the main config file with a higher priority than the one of the files in the subfolder (drop-in), in this case option \fB-i\fR should be used.
.TP
py-ini-config get Journal SystemMaxUse -a /usr/lib/systemd/journald.conf -a /run/systemd/journald.conf -a /etc/systemd/journald.conf --sort-collected --shadowing -e conf
Let us consider the case for config files \fBsystemd\fR. This command gets the last found value of the \fBSystemMaxUse\fR variable from the section \fBJournal\fR. The option \fB--sort-collected\fR works in the following way:
.RS 11
1) at first the files \fB/usr/lib/systemd/journald.conf\fR, \fB/run/systemd/journald.conf\fR, \fB/etc/systemd/journald.conf\fR are looked through;
.RS 0
2) then all the files are collected from the folders \fB/usr/lib/systemd/journald.conf.d/*.conf\fR, \fB/run/systemd/journald.conf.d/*.conf\fR and \fB/etc/systemd/journald.conf.d/*.conf\fR are sorted in the alphabetical order not depending on the subfolder they are in, and are read after having been sorted.
.RS -4
Due to the option \fB-e conf\fR only the files with the extension \fB.conf\fR are looked through in the subfolders. The option \fB--shadowing\fR allows to take into consideration the mechanism when the files with the same basename from the following subfolder replace the files from the previous subfolder. In other words, the file \fB/etc/systemd/journald.conf.d/50-test.conf\fR will replace \fB/usr/lib/systemd/journald.conf.d/50-test.conf\fR and the file \fB/run/systemd/journald.conf.d/50-test.conf\fR, namely will fully exclude these files from the looked through ones.
.SH AUTHOR
MOS Team\&
.P

